#include <stdafx.h>
#include "LitEditorMetaObject.h"

unsigned long Lit::Editor::MetaObject::RefCount = 0;


Lit::Editor::MetaObject::MetaObject( const std::string &name )
{
	RefCount ++;
}
Lit::Editor::MetaObject::~MetaObject( ){if( RefCount != 0 ) RefCount --; }

const std::string& Lit::Editor::MetaObject::getInfo( const std::string &name ){ if( !hasInfo( name ) ) setInfo( name, "" ); return mInfos[name]; }
void Lit::Editor::MetaObject::setInfo( const std::string &name, const std::string &value ){ mInfos[name] = value; }
bool Lit::Editor::MetaObject::hasInfo( const std::string &name ) const{ return ( mInfos.find(name) != mInfos.end());}
void Lit::Editor::MetaObject::clearInfos(){ mInfos.clear(); }

std::string Lit::Editor::MetaObject::NameGenerator( const std::string &prefix, const std::string &suffix, const std::string &separator )
{
	std::stringstream ss(prefix+separator);
	ss << RefCount;
	ss << separator << suffix;
	return ss.str();
}